<template>
  <div>
    <ul class="navbar">
      <li
        v-for="item in tabItemDate"
        :key="item.id"
      >
        <a :class="item.id == hotIndex ? 'active' : ''" 
        @mouseenter="setHotIndex(item.id)">
          {{ item.area }}
        </a>
      </li>
    </ul>
    <div class="conlist">
      <div
        class="conlist-item"
        v-for="item in iteminfoItem.childrenOneItem"
        :key="item.id"
      >
        <h4>{{ item.name }}</h4>
        <ul class="col">
          <li
            v-for="childrenItem in item.childrenTwoItem"
            :key="childrenItem.id"
          >
            <a href="#">{{ childrenItem.name }}</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
export default {
  name: "Hot",
  props: ["iteminfo", "tabItemDate"],
  mounted() {
    // console.log(this.hotIndex);
  },
  computed: {
    ...mapState({
      hotIndex: (state) => state.destination.hotIndex,
    }),
    iteminfoItem: {
      get() {
        if (!this.tabItemDate) return {};
        return this.tabItemDate.find((item) => item.id == this.hotIndex);
      },
      set(val) {
        console.log(val);
      },
    },
  },
  methods: {
    ...mapActions("destination", ["setHotIndex"]),
  },
};
</script>

<style lang="stylus" scoped>
.navbar {
  display: flex;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 20px;

  li a {
    color: #333;
    display: inline-block;
    margin: 0 25px;
    vertical-align: top;
    text-decoration: none;
    padding-bottom: 10px;
    cursor: pointer;

    &.active {
      border-bottom: 3px solid #ff9d00;
      color: #ff9d00;
    }
  }
}

.conlist {
  width: 800px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;

  .conlist-item {
    width: 50%;
    box-sizing: border-box;
    font-size: 16px;
    display: flex;
    padding: 10px 15px;
    line-height: 30px;

    h4 {
      width: 100px;
      text-decoration: underline;
      flex-shrink: 0;
    }

    .col {
      display: flex;
      flex-wrap: wrap;

      li {
        margin-left: 10px;
      }
    }
  }
}
</style>